/**
 * 用于 块状列表 模块
 */
const Pager = require('../../components/aotoo/core/index')
const lib = Pager.lib
const cd = lib.cd

const adapter = (data) => {
  return data.map(item => {
    return {
      title: {title: item.time, itemClass: 'item-title'},
      dot: [{title: item.distance, itemClass: 'item-desc'}],
      itemClass: 'ss-diaplay-list-item',
      aim: item.aim ? 'onJumpPages?path='+item.aim : ''
    }
  })
}

module.exports = function(params={}) {
  let dft = {
    // listClass: 'ss-display-list'
  }
  let opts = Object.assign({}, dft, params)
  let type = opts.type == 'scroll' ? {
    is: 'scroll',
    'scroll-y': true
  } : opts.type == 'swiper' ? {
    is: 'swiper'
  } : {}
  console.log(opts.data);
  return {
    listClass: ('ss-display-list ' + opts.listClass),
    itemClass: opts.itemClass,
    type: type,
    data: adapter(opts.data),
    itemMethod: {
      onJumpPages(e, params, inst) {
        const $path = params.patn
        wx.navigateTo({
          url: $path
        })
      }
    }
  }
}
